package com.tencet.servlet;

import com.tencet.entity.AccountTwo;
import com.tencet.service.AccountTwoService;
import com.tencet.service.Impl.AccountTwoServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: Fame
 * @date: 2022-07-20 16:31
 * @description:
 */
@WebServlet("/account2")
public class AccountTwoServlet extends HttpServlet {
    private AccountTwoService accountTwoService = new AccountTwoServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String card_num = req.getParameter("card_num");
        String id = accountTwoService.getId(card_num);
        AccountTwo accountTwo = accountTwoService.getBeanById(id);
        req.getSession().setAttribute("accountTwo",accountTwo);
        req.getRequestDispatcher("account1?idTwo=" + accountTwo.getAccount_id2()).forward(req,resp);
    }
}
